﻿using System;
using System.Collections.Generic;
using System.Text;

namespace mstdump_Analyzer
{
    class CardFwVer : DeviceFwVerInterface
    {
        //HCAFwVer:            
        private string MAJOR = ""; //="0x1f064.16"        //    MAJOR_size=16
        private string MINOR = ""; //="0x1f068.16"        //    MINOR_size=16
        private string SUBMINOR = ""; //="0x1f068.0"      //    SUBMINOR_size=16
        private string Hour = ""; //="0x1f06c.8"          //    Hour_size=8
        private string Minutes = ""; //="0x1f06c.16"      //    Minutes_size=8
        private string Seconds = ""; //="0x1f06c.24"      //    Seconds_size=8
        private string Day = ""; //="0x1f070.0"           //    Day_size=8
        private string Month = ""; //="0x1f070.8"         //    Month_size=8
        private string Year = ""; //="0x1f070.16"         //    Year_size=16
        //
        //----------------------------------------------------
        //
        public string getFwVer()
        {
            return "Version: " + MAJOR + "." + MINOR + "." + SUBMINOR
                + "\r\nBuild time: " + Month + "." + Day + "." + Year + " " + Hour + ":" + Minutes + ":" + Seconds;
        }
        //
        //----------------------------------------------------
        //
        public void identifyFW(Dictionary<string, string> mstdumpDic)
        {
            MAJOR = Methods.Hex2decString(Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f064"), 16, 16)); //="0x1f064.16"        //    MAJOR_size=16
            MINOR = Methods.Hex2decString(Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f068"), 16, 16)); //="0x1f068.16"        //    MINOR_size=16
            SUBMINOR = Methods.Hex2decString(Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f068"), 0, 16));  //="0x1f068.0"      //    SUBMINOR_size=16
            
            Hour = Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f06c"), 8, 8); //="0x1f06c.8"          //    Hour_size=8
            if (Hour.Length == 1)
            {
                Hour = "0" + Hour;
            }
            Minutes = Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f06c"), 16, 8); //="0x1f06c.16"      //    Minutes_size=8
            if (Minutes.Length == 1)
            {
                Minutes = "0" + Minutes;
            }
            Seconds = Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f06c"), 24, 8); //="0x1f06c.24"      //    Seconds_size=8
            if (Seconds.Length == 1)
            {
                Seconds = "0" + Seconds;
            }
            Day = Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f070"), 0, 8); //="0x1f070.0"           //    Day_size=8
            Month = Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f070"), 8, 8); //="0x1f070.8"         //    Month_size=8
            Year = Methods.GetValueFromOffset(Methods.SafeDicGetter(mstdumpDic,"1f070"), 16, 16); //="0x1f070.16"         //    Year_size=16
        }
        //
        //----------------------------------------------------
        //
    }
}
